<template>
  <div class="box">
    <div class="title" v-if="History.length > 0">
      <h3>搜索历史</h3>
      <p @click="historyClear()"><span class="iconfont">&#xe7aa;</span></p>
    </div>
    <div class="content">
      <span v-for="item in History" :key="item" @click="hot(item)">{{
        item
      }}</span>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
export default {
  name: "VueMusicSearchHistory",
  data() {
    return {};
  },

  mounted() {},
  computed: {
    ...mapGetters(["History"]),
  },
  methods: {
    hot(hot) {
      this.$parent.onSearch(hot);
    },
    historyClear() {
      this.$store.commit("SET_SEARCH_HISTORY_SLICE");
    },
  },
};
</script>

<style lang="less" scoped>
.box {
  .title {
    display: flex;
    justify-content: space-between;
    margin: 0rem .625rem 0 .9375rem;
    height: 1.875rem;
    line-height: 1.875rem;
    h3 {
      font-weight: bold;
      color: grey;
    }
    span{font-size: 1rem;}
  }
  .content {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin: 0rem .9375rem;
    border-radius: .3125rem;
    span {
      background-color: #f5f5f5;
      border-radius: .1875rem;
       font-size: 14px;
    line-height: 16px;
    padding: 5px 10px;
    margin: 5px;
    border-radius: 14px;
    color: #535353;
  
    }
  }
}
</style>